package com.example.myactspringboot.listener;

import com.example.myactspringboot.bean.BusiTaskMain;
import com.example.myactspringboot.dao.BusiTaskMainMapper;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class EndExecutionListener implements ExecutionListener {
    @Autowired
    private BusiTaskMainMapper mainMapper;
    public static EndExecutionListener listener;
    @PostConstruct
    public void init() {
        listener = this;
        listener.mainMapper = this.mainMapper;
    }

    @Override
    public void notify(DelegateExecution execution) {
        BusiTaskMain byId = listener.mainMapper.getById(1);
        System.out.println("结束执行");
        System.out.println(execution.getProcessInstanceId());
        BusiTaskMain byInstId = listener.mainMapper.getByInstId(execution.getProcessInstanceId());
        byInstId.setState("2");
        int i = listener.mainMapper.updateMain(byInstId);
        System.out.println(execution);
    }


}
